#include <iostream>
#include <fstream>
#include <string>

// 抽象接口
class ILogger {
public:
    virtual ~ILogger() {}
    virtual void logMessage(const std::string& message) = 0;
};

// 具体实现：文件日志记录
class FileLogger : public ILogger {
public:
    void logMessage(const std::string& message) override {
        std::ofstream logFile("log.txt", std::ios::app);
        logFile << message << std::endl;
        logFile.close();
    }
};

// 高层模块
class Application {
private:
    ILogger& logger;
public:
    Application(ILogger& logger) : logger(logger) {}
    void process() {
        logger.logMessage("Process started.");
        // 更多业务逻辑...
        logger.logMessage("Process finished.");
    }
};

// 在客户端代码中使用
int main() {
    FileLogger fileLogger;
    Application app(fileLogger);
    app.process();
    return 0;
}